import { request } from "@/utils/http";
import { AddHospitalSetParams, GetHostpitalSetParams, GetHostpitalSetResponse, HospitalSetItem, UpdateHospitalSetParams } from "./model/hospitalSet";
import React from 'react';

//封装函数发送请求获取医院设置的列表数据
export function reqGetHospitalSet({limit, page, hosname, hoscode}: GetHostpitalSetParams){
  //发送 AJAX 请求
  return request.get<any, GetHostpitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
    // ?a=100&b=200
    params: {
      hosname: hosname,
      hoscode: hoscode
    }
  });
}

//封装函数新增医院设置
export function reqAddHostpitalSet(params: AddHospitalSetParams){
  return request.post<any, null>('/admin/hosp/hospitalSet/save', params);
}

//封装函数更新医院设置
export function reqUpdateHospitalSet(params: UpdateHospitalSetParams){
  return request.put<any, null>('/admin/hosp/hospitalSet/update', params);
}

//封装函数获取单个医院的数据
export function reqGetHospitalSetItem(id: string){
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}

//封装函数删除单个医院的数据
export function reqRemoveHospitalSetItem(id: string){
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
}

//封装函数批量删除医院数据
export function reqBatchRemoveHospitalSet(ids: React.Key[]){
  return request.delete('/admin/hosp/hospitalSet/batchRemove', {
    data: ids
  })
}